jQuery(document).ready(function() {

	//alert(window.innerWidth);


   jQuery(window).on("load resize", function(){
     if (window.matchMedia("(orientation: landscape)").matches) {
	if(document.documentElement.clientWidth == '1280'){
   	jQuery('div#b-you-might ul.products-grid li.item').css('width','186px', 'important');
	}

       if(document.documentElement.clientWidth == '1024'){
       jQuery('.customer-ctrl').css('display','none', 'important');
       }

     }

   });

   if(jQuery('a#b-you-might').css('display') == 'none' && jQuery('a#b-recently-viewed').css('display') == 'none'){
	jQuery('div#reco-container-product').css('display','none');
   }

   if(jQuery('a#b-you-might').css('display') == 'none'){
	jQuery('.online-gallery').css('width','982px', 'important');
	jQuery('div#b-recently-viewed ul.products-gale').css('width','982px', 'important');
	jQuery('div#b-you-might').css('display','none','important');
	jQuery('div#b-recently-viewed').css('display','block','important');
	jQuery('p#par2').show().css({"margin-left":"0px","position":"relative","left":"0px"});
   }

   if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==9){
   	jQuery('div#b-you-might ul.products-grid li.item').css('width','186px', 'important');
	jQuery('div#best-sellers ul.products-gale li.item').css('width','186px', 'important');
   }	

   if(document.documentElement.clientWidth == '1024'){
     jQuery('.customer-ctrl').css('display','none', 'important');
   }


   if(document.documentElement.clientWidth == '768'){
     jQuery('.por-768').css('margin-left','310px');
     jQuery('.price-box').css('margin-left','310px');
   }

   if(document.documentElement.clientWidth == '320'){
     document.cookie="width=" + "yes" + "; path=/";
         if( /IEMobile/i.test(navigator.userAgent) ) {
          jQuery('div#recently-viewed ul.products-gale li.item').css('left','70px');
	   jQuery('div#b-recently-viewed ul.products-grid li.item').css('left','70px');
          jQuery('p#par2').css('margin-top','45px');
         }
         if( /Android/i.test(navigator.userAgent) ) {
          jQuery('div#recently-viewed ul.products-gale li.item').css('left','85px');
          jQuery('div#b-recently-viewed ul.products-grid li.item').css('left','85px');
	   jQuery('p#par2').css('margin-top','45px');
         }
         if( /iPhone/i.test(navigator.userAgent) ) {
	   jQuery('div#b-you-might ul.products-grid').css('width','96%', 'important');
	   jQuery('div#b-you-might ul.products-grid li.item').css('width','50%', 'important');
	   jQuery('div#b-you-might ul.products-grid li.item').css('padding-left','2px');
	   jQuery('p#par2').css('margin-top','45px');
        }

   }
   else
     document.cookie="width=" + "no" + "; path=/";


    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==8){
	//alert("IE8888");
	jQuery('div#best-sellers ul.products-gale').css('left','110px', 'important');
	jQuery('div#best-sellers ul.products-gale li.item').css('width','314px', 'important');
	jQuery('div#best-sellers ul.products-gale li.item .product-like').css('top','165px', 'important');
       jQuery('.online-gallery').css('width','982px', 'important');
	jQuery('div#b-you-might ul.products-grid').css('width','982px', 'important');
	jQuery('div#b-you-might ul.products-grid').css('left','110px', 'important');
	jQuery('div#b-you-might ul.products-grid li.item').css('width','350px', 'important');
	jQuery('#reco-container-product .products-grid LI.item .product-like').css('top','165px', 'important');
	jQuery("#breadcrumb-product-name").css({"top":"80px","position":"relative","width":"200%"});
    }	

    if (jQuery.browser.safari){
	jQuery('div#b-you-might ul.products-grid li.item h3.product-name').css('font-size','14px', 'important');
    }


   jQuery('.position1').click(function () {	
   	window.location = jQuery('.position1').attr('href');
   });
	
   jQuery('.name1').click(function () {			
       window.location = jQuery(".name1").attr('href');
   });

   jQuery('.price1').click(function () {	
       window.location = jQuery(".price1").attr('href');
   });

jQuery('a#a-best-sellers').click(function(){ 
    jQuery('div#best-sellers').show();
    jQuery('div#recently-viewed').hide();
    jQuery('a#a-best-sellers').css('color','#1853A3');
    jQuery('a#a-recently-viewed').css('color','#000');
    jQuery('p#par1').show();
    jQuery('p#par2').hide();

    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==9){
	jQuery('div#best-sellers ul.products-gale li.item').css('width','186px', 'important');
    }	

    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==8){
       jQuery('div#best-sellers ul.products-gale').css('left','110px', 'important');
	jQuery('div#best-sellers ul.products-gale li.item').css('width','186px', 'important');
	//alert("bestseller");
	//jQuery('.online-gallery li').css('width','20%');
	//jQuery('#b-you-might li, #best-sellers li, #a-recently-viewed li').css({"width":"168px!important","float":"left","overflow":"visible"});

    }	

	

}); 

jQuery('a#a-recently-viewed').click(function(){ 
    jQuery('div#recently-viewed').show();
    jQuery('div#best-sellers').hide();
    jQuery('a#a-recently-viewed').css('color','#1853A3');
    jQuery('a#a-best-sellers').css('color','#000');
    jQuery('p#par1').hide();
    jQuery('p#par2').show();
    jQuery('div#recently-viewed, p#par2').css({"margin-left":"0px","position":"relative","left":"0px"});

    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==9){
	jQuery('div#recently-viewed ul.products-gale li.item').css('width','186px', 'important');
    }	

    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==8){
	jQuery('.online-gallery').css('width','982px', 'important');
       jQuery('div#recently-viewed ul.products-gale').css('left','110px', 'important');
	jQuery('div#recently-viewed ul.products-gale').css('width','982px', 'important');
	jQuery('div#recently-viewed ul.products-gale li.item').css('width','350px', 'important');
	jQuery('div#recently-viewed ul.products-gale li.item .product-like').css('top','165px', 'important');
    }	
}); 

 
jQuery('a#b-you-might').click(function(){ 

    jQuery('div#b-you-might').show();
    jQuery('div#b-recently-viewed').hide();
    jQuery('a#b-you-might').css('color','#1853A3');
    jQuery('a#b-recently-viewed').css('color','#000');

    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==9){
   	jQuery('div#b-you-might ul.products-grid li.item').css('width','186px', 'important');
    }	

    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==8){
	//alert("TRY");
	jQuery('.online-gallery').css('width','982px', 'important');
	jQuery('div#b-you-might ul.products-grid').css('width','982px', 'important');
	jQuery('div#b-you-might ul.products-grid').css('left','110px', 'important');
	jQuery('div#b-you-might ul.products-grid li.item').css('width','350px', 'important');
	jQuery('#reco-container-product .products-grid LI.item .product-like').css('top','165px', 'important');
	//alert("225");
	//jQuery('.online-gallery li').css('width','168px!important');
    }	
	


    if (window.matchMedia("(orientation: landscape)").matches) {
 	if(document.documentElement.clientWidth == '1280'){
   	jQuery('div#b-you-might ul.products-grid li.item').css('width','186px', 'important');
	}
    }
}); 

jQuery('a#b-recently-viewed').click(function(){ 
    jQuery('div#b-recently-viewed').show();
    jQuery('div#b-you-might').hide();
    jQuery('a#b-recently-viewed').css('color','#1853A3');
    jQuery('a#b-you-might').css('color','#000');
    jQuery('p#par2').show().css({"margin-left":"0px","position":"relative","left":"0px"});

    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==9){
   	jQuery('div#b-recently-viewed ul.products-grid li.item').css('width','186px', 'important');
    }	

    if ( jQuery.browser.msie && jQuery.browser.version.substr(0, 1)==8){
	//jQuery('#reco-container-product .products-grid LI.item').css('width','186px', 'important');
	jQuery('.online-gallery').css('width','982px', 'important');
       jQuery('div#b-recently-viewed ul.products-grid').css('left','110px', 'important');
	jQuery('div#b-recently-viewed ul.products-grid').css('width','982px', 'important');
	jQuery('div#b-recently-viewed ul.products-grid li.item').css('width','350px', 'important');
	jQuery('div#b-recently-viewed ul.products-grid li.item .product-like').css('top','165px', 'important');
    }	
}); 

jQuery('div#recently-viewed').insertAfter('div#best-sellers');
jQuery('p#par1').insertAfter('span#phones');
/*jQuery('p#par2').insertAfter('span#phones');*/

 jQuery("#myCarousel").swiperight(function() {  
                jQuery("#myCarousel").carousel('prev');  
            });  
 
            jQuery("#myCarousel").swipeleft(function() {  
                jQuery("#myCarousel").carousel('next');  
            });  
            jQuery('#prev').click(function(){
                jQuery('.carousel').carousel('prev');
            });
            jQuery('#next').click(function(){
                jQuery('.carousel').carousel('next');
            });
            /*jQuery('#myCarousel').carousel({
              interval: 3000
            });*/
});
/*
jQuery( function() {
	jQuery(window).bind('load', function() {
		jQuery('div#recently-viewed').css('margin-left','-10000px');
		jQuery('p#par2').hide();
		jQuery('div#recently-viewed').hide();
	});
});*/